#include "head.h"


// 初始化信息
// 按照指定个数启动线程, 启动
int initPool(pool_t *pool, int num){

    // 先信息初始化
    pool->list = (pthread_t *)calloc(num, sizeof(pthread_t));
    pool->num = num;

    memset(&pool->queue, 0, sizeof(pool->queue));

    pthread_mutex_init(&pool->lock, NULL); 
    pthread_cond_init(&pool->cond, NULL);

    // 再启动子线程
    for(int i=0; i<num; i++){
        pthread_create(&pool->list[i], NULL, threadMain, pool);
    }
    
    pool->exitFlag = 0;
    return 0;
}

